package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.ContentCount;

public class ContentCountValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return ContentCount.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "contentId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "views", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "viewsMonth", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "viewsWeek", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "viewsDay", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "comments", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "commentsMonth", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "commentsWeek", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "commentsDay", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "downloads", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "downloadsMonth", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "downloadsWeek", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "downloadsDay", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ups", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "upsMonth", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "upsWeek", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "upsDay", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "downs", "required");
	}

}
